package org.fujene.toolbox;

/**
 * ハッシュ生成器です。
 * 
 * @author fujisaka_yusuke
 */
public class ContentHash{
	public static long getTermHash(String str){
		return Long.rotateLeft(str.hashCode() * 0x123456789ABCDEF1L ^ 0x5555555555555555L, 35);
	}

	public static long getContentHash(long docID){
		return Long.rotateLeft(docID * 0x123456789ABCDEF1L ^ 0xAAAAAAAAAAAAAAAAL, 42);
	}

	public static boolean compareRange(long current, long from, long to){
		if(current >= 0){
			if(from >= 0 && current >= from) if((to >= 0 && current <= to) || (to < 0)) return true;
		}else{
			if((from >= 0) || (from < 0 && current >= from)) if(to < 0 && current <= to) return true;
		}
		return false;
	}
}
